package jia.ai;

import org.apache.log4j.Logger;

/**
 * A* algorithm node information.
 *
 * @version 1.0
 * @since 01/22/2006
 */
public final class NodeInfo implements Comparable{
    private final Object node;
    private double costFromStart;
    private NodeInfo parentNodeInfo;
    private double totalCost;
    
    private static final Logger log = Logger.getLogger(NodeInfo.class);
    
    /**
     * @param node
     */
    public NodeInfo(Object node){
        NullArgumentException.check(this.node = node);
    }
    
    /**
     * @return
     */
    public double getCostFromStart(){
        return costFromStart;
    }
    
    /**
     * @return
     */
    public Object getNode(){
        return node;
    }
    
    /**
     * @return
     */
    public NodeInfo getParentNodeInfo(){
        return parentNodeInfo;
    }
    
    /**
     * @return
     */
    public double getTotalCost(){
        return totalCost;
    }
    
    /**
     * @param costFromStart
     */
    public void setCostFromStart(double costFromStart){
        this.costFromStart = costFromStart;
    }
    
    /**
     * @param parentNodeInfo
     */
    public void setParentNodeInfo(NodeInfo parentNodeInfo){
        NullArgumentException.check(this.parentNodeInfo = parentNodeInfo);
    }
    
    /**
     * @param totalCost
     */
    public void setTotalCost(double totalCost){
        this.totalCost = totalCost;
    }
    
    /**
     * @param other
     *
     * @return
     */
    public int compareTo(Object other){
        NodeInfo otherNodeInfo = (NodeInfo) other;
        double otherTotalCost = otherNodeInfo.totalCost;
        if(totalCost < otherTotalCost) {
            return -1;
        }
        if(totalCost > otherTotalCost) {
            return 1;
        }
        return 0;
    }
}